package com.support.utils;

import android.content.res.ColorStateList;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.ColorRes;
import androidx.annotation.DrawableRes;
import androidx.core.content.ContextCompat;
import androidx.databinding.BindingAdapter;

import com.example.plugin_native.R;

public class DataBindingAdapter {
    @BindingAdapter("tintColor")
    public static void setTintColor(ImageView imageView, @ColorRes int color) {
        imageView.setImageTintList(ColorStateList.valueOf(ContextCompat.getColor(imageView.getContext(), color)));
    }

    @BindingAdapter("selector")
    public static void setSelector(TextView textView, String res) {
        if (res.equals(textView.getText().toString())) {
            textView.setBackgroundResource(R.drawable.bg_circle_green_light_color);
            textView.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.text_green));
        } else {
            textView.setBackgroundResource(R.drawable.bg_circle_gray_color);
            textView.setTextColor(ContextCompat.getColor(textView.getContext(), R.color.text_gray));

        }
    }

    @BindingAdapter("imageSrc")
    public static void setImageSrc(ImageView imageView, String color) {
        if (color.equals(imageView.getTag().toString())) {
            imageView.setImageResource(R.drawable.bg_circle_black_tran_color);
        } else {
            imageView.setImageResource(R.color.tran);

        }
    }
}
